package com.starsoft.quant.strategy.bank;

import java.util.Date;

public class Cashflow implements Comparable<Cashflow> {

	private double amount;
	private Date date;
	private double factor;

	private double timeToEnd;

	public Cashflow(double amount, Date date) {
		super();
		this.amount = amount;
		this.date = date;
		this.factor = 1;
	}

	public Cashflow(double amount, Date date, double factor) {
		super();
		this.amount = amount;
		this.date = date;
		this.factor = factor;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public double getFactor() {
		return factor;
	}

	public void setFactor(double factor) {
		this.factor = factor;
	}

	@Override
	public int compareTo(Cashflow cashflow) {
		if (cashflow == null) {
			return 1;
		} else if (date.after(cashflow.getDate())) {
			return 1;
		} else if (date.before(cashflow.getDate())) {
			return -1;
		}
		return 0;
	}

	public double getTimeToEnd() {
		return timeToEnd;
	}

	public void setTimeToEnd(double timeToEnd) {
		this.timeToEnd = timeToEnd;
	}

	@Override
	public String toString() {
		return "Cashflow [amount=" + amount + ", date=" + date + ", factor=" + factor + ", timeToEnd=" + timeToEnd
				+ "]";
	}

}
